#include "myLog.h"
#include <syslog.h>
#include <string.h>

static LogConfig logConfig ={
    .processName = NULL,
    .facility = LOG_USER,
    .level = LOG_LEVEL_INFO
};

int log_init(const char *processname,int facility,LogLevel level){
    
    logConfig.processName = processname;
    logConfig.facility = facility;
    logConfig.level = level;

    // 初始化syslog
    openlog(processname, LOG_CONS | LOG_PID , facility);

    
    // 设置日志过滤级别
    setlogmask(LOG_UPTO(logConfig.level));

    LOG(LOG_INFO,"system", "Log system initialized: processName=%s, facility=%d, level=%d",
             processname, facility, level);

    return 0; // 成功返回0
}

int log_close(void) {
    LOG(LOG_INFO,"system", "Log system shutting down");
    closelog();
    return 0; // 成功返回0
}

